﻿using AppMVVM.Models;
using AppMVVM.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace AppMVVM.Views
{
    /// <summary>
    /// Interaction logic for FeedReader.xaml
    /// </summary>
    public partial class FeedReader : Window
    {
        private UserControl _articleListControl;

        private static FeedReader _instance;

        public static FeedReader Instance
        {
            get
            {
                if (_instance == null)
                    _instance = new FeedReader();
                return _instance;
            }
        }

        private FeedReader()
        {
            _articleListControl = new ArticleListView();

            InitializeComponent();
        }
        private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            Source source = e.NewValue as Source;

            if (source != null)
            {
                /*
                var viewModel = ArticleListViewModel.Instance;
                viewModel.Source = source;
                
                _articleListControl.DataContext = viewModel;
                */
                this.container.Content = _articleListControl;
                this.container.DataContext = source;
            }
        }
    }
}
